using System;
using System.ComponentModel.DataAnnotations;
using Microsoft.EntityFrameworkCore;

namespace Terra.Data.Entities;

/// <summary>
/// 审计实体基类
/// </summary>
/// <typeparam name="TKey">主键类型</typeparam>
public abstract class AuditEntityBase<TKey> : EntityBase<TKey>, IAuditEntity, ISoftDelete
{
    /// <summary>
    /// 创建时间
    /// </summary>
    public DateTime CreatedTime { get; set; } = DateTime.UtcNow;

    /// <summary>
    /// 创建者ID
    /// </summary>
    [Comment("创建者ID")]
    public Guid? CreatedBy { get; set; }

    /// <summary>
    /// 最后修改时间
    /// </summary>
    public DateTime? LastModifiedTime { get; set; }

    /// <summary>
    /// 最后修改者ID
    /// </summary>
    [Comment("最后修改者ID")]
    public Guid? LastModifiedBy { get; set; }

    /// <summary>
    /// 是否已删除
    /// </summary>
    public bool IsDeleted { get; set; }

    /// <summary>
    /// 删除时间
    /// </summary>
    public DateTime? DeletedTime { get; set; }

    /// <summary>
    /// 删除者ID
    /// </summary>
    [Comment("删除者ID")]
    public Guid? DeletedBy { get; set; }
}

// 为了方便使用，可以创建一个默认的实现
/// <summary>
/// 默认使用Guid作为用户ID的审计实体基类
/// </summary>
public abstract class AuditEntityBase<TKey, TUserKey> : AuditEntityBase<TKey>
{
}